package com.shunwang.errors.engine.builder.bean;

import java.util.ArrayList;
import java.util.List;

public class NodeBean {

	private String clazz;
	private List<NodeMethod> method = new ArrayList<NodeMethod>();
	
	public String getClazz() {
		return clazz;
	}
	public void setClazz(String clazz) {
		this.clazz = clazz;
	}
	public List<NodeMethod> getMethod() {
		return method;
	}
	public void setMethod(NodeMethod method) {
		this.method.add(method);
	}
	
	public boolean contains(NodeMethod nodeBean){
		return method.contains(nodeBean);
	}
	
	public boolean containsClazz(String clazzName){
		return this.clazz.equals(clazzName);
	}
	
	public boolean contains(String methodName,String handlerName){
		for(NodeMethod node:method){
			if(node.contains(methodName, handlerName)){
				return true;
			}
		}
		return false;
	}
	
	public NodeMethod getNodeMethod(String methodName,String handlerName){
		for(NodeMethod node:method){
			if(node.contains(methodName, handlerName)){
				return node;
			}
		}
		return null;
	}
	

	
	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof NodeBean)){
			return false;
		}
		NodeBean bean = (NodeBean)obj;
		if(clazz.equals(bean.getClazz())){
			return true;
		}
		return false;
	}
	
}
